import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';

import 'option_name.dart';

part 'option.g.dart';

@JsonSerializable(explicitToJson: true)
class Option extends Equatable {
  @override
  List<Object> get props => [optionId, optionName, orderValue, optionNames,inventory,allowEdit];

  factory Option.fromJson(Map<String, dynamic> json) => _$OptionFromJson(json);

  Map<String, dynamic> toJson() => _$OptionToJson(this);

  final String optionId;

  final String optionName;

  final String orderValue;

  final List<OptionName> optionNames;

  final String price;

  final String inventory;

  final bool allowEdit;

  @JsonKey(defaultValue: true)
  final bool isSelect;

  Option(this.optionId, this.optionName, this.orderValue, this.optionNames,this.allowEdit,
      {this.price, this.inventory, this.isSelect = true});

  Option copyWith({
    String optionId,
    String optionName,
    String orderValue,
    List<OptionName> optionNames,
    bool isSelect,
    String price,
    String inventory,
    bool allowEdit,
  }) {
    return Option(
      optionId ?? this.optionId,
      optionName ?? this.optionName,
      orderValue ?? orderValue,
      optionNames ?? optionNames,
      allowEdit ?? this.allowEdit,
      isSelect: isSelect ?? this.isSelect,
      price: price ?? this.price,
      inventory: inventory ?? this.inventory
    );
  }
}
